package net.cjw.initsb.controller.background;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import net.cjw.initsb.common.ServiceResult;
import net.cjw.initsb.common.ServiceResult.ServiceResultMsg;
import net.cjw.initsb.service.QuartzTaskLogServiceI;

@Api(description = "定时任务日志")
@RestController
@RequestMapping("quartz_task_log")
public class QuartzTaskLogController {

	Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private QuartzTaskLogServiceI quartzTaskLogServiceI;

	@GetMapping("v{version}/select_all")
	public ServiceResult<Object> taskLogSelectAll(
			@ApiParam(value = "版本号", defaultValue = "1") @PathVariable("version") Integer version,
			@ApiParam(value = "页数", defaultValue = "1") @RequestParam Integer page_num,
			@ApiParam(value = "数据库最大结果数", defaultValue = "10") @RequestParam Integer max_result) {
		if (page_num == null || max_result == null) {
			return ServiceResult.buildError(ServiceResultMsg.REQUEST_PARAM_ERROR_MSG);
		}
		if (version == 1) {
			return quartzTaskLogServiceI.selectAll(page_num, max_result);
		}
		return ServiceResult.buildError(ServiceResultMsg.VERSION_ERROR_MSG);
	}

}
